<?php

namespace mpend\models\searchs;

use Yii;
use common\helpers\DateHelper;

/**
 * 需求分类栏目检索
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class DemandCategorySearch extends \common\models\demand\DemandCategory {

    /**
     * @inheritdoc
     */
    public function buildQuery($alias = 't') {
        $query = static::find();
        if ($alias) {
            $query->alias($alias);
            $alias .= '.';
        }
        $query->active(static::STATUS_ACTIVE);
        $query->orderBy([
            $alias . 'navbar' => SORT_DESC,
            $alias . 'listorder' => SORT_DESC,
        ]);
        return $query;
    }

    /**
     * @inheritdoc
     */
    public function fields() {
        return [
            'id',
            'title' => 'name',
            'icon',
            'cover' => 'icon',
            'description',
            'link' => 'mpPage',
        ];
    }

}
